<template>
  <div class="superinspection">
    <div class="ListData" v-if="cityName.length > 0">
      <ul
        v-for="(item, index) in cityName"
        :key="index"
        class="ListData-ul"
        @click="SelectGoto(item)"
      >
        <li class="ListData-name">
          {{ item.cityName }}
        </li>
        <li class="ListData-XZQH">
          行政区划:<span>{{ XZQHName }}</span>
        </li>
        <li class="ListData-FWNum">
          与房屋建筑和市政设施调查系统符合情况:
          <span
            >共督查{{ item.totalHouseNum }}个房屋，{{
              item.matchHouseNum
            }}个相符、{{ item.baseMatchHouseNum }}个基本相符、
            {{ item.notMatchHouseNum }}个不相符。其中生产经营性房屋督查{{
              item.operateHouseTotalHouse
            }}个房屋，{{ item.operateMatchHouseNum }} 个相符、{{
              item.operateBaseMatchHouseNum
            }}个基本相符、{{ item.operateNotMatchHouseNum }}个不相符
          </span>
        </li>
      </ul>
    </div>
    <div v-else style="height: 99vh; text-align: center; padding-top: 20vh">
      <div style="margin-bottom: 10px">
        <img
          src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png"
        />
      </div>
      <div>暂无数据</div>
    </div>
  </div>
</template>
<script>
import { houseCheckSupervisionFwCheckList } from "../../../utils/api";
import dd from "gdt-jsapi";
export default {
  data() {
    return {
      //省市区
      SXQ: "",
      cityName: [],
      //区分当前点击的是市区县
      isCity: 0,
      XZQHName: "",
    };
  },
  methods: {
    //根据citycode区分市区县镇街道
    discriminateCity(str) {
      if (str.endsWith("0000000000")) {
        //省
        this.isCity = 0;
      } else if (str.endsWith("00000000")) {
        //市
        this.isCity = 1;
      } else if (str.endsWith("000000")) {
        //区
        this.isCity = 2;
      } else if (str.endsWith("000")) {
        //街道
        this.isCity = 3;
      } else {
        //村
        this.isCity = -1;
      }
    },
    SelectGoto: async function (data) {
      this.discriminateCity(data.cityCode);
      let parmes = {
        cityCode: data.cityCode,
        houseUse: 6,
        masterName: "",
        pageNo: 0,
        pageSize: 0,
        roleType: window.sessionStorage.getItem('citycodeRoleD'),
      };
      if (this.isCity == 1||this.isCity == 2||this.isCity == 3) {
        if (
        window.sessionStorage.getItem("citycodeRoleD") == "0" &&
        window.sessionStorage.getItem("SelectCityD") == "1"
      ) {
        parmes.roleType = 1;
      } else if (
        window.sessionStorage.getItem("citycodeRoleD") == "0" &&
        window.sessionStorage.getItem("SelectCityD") == "2"
      ) {
        parmes.roleType = 2;
      } else if (
        window.sessionStorage.getItem("citycodeRoleD") == "1" &&
        window.sessionStorage.getItem("SelectCityD") == "2"
      ) {
        parmes.roleType = 2;
      }
        const res = await houseCheckSupervisionFwCheckList(parmes);
        this.cityName = res.data.data;
        console.log(window.sessionStorage.getItem('citycodeQXNameD'),'kkkk')
        this.XZQHName = this.XZQHName+"  " + data.cityName;
      }  else {
        //选中了村 前去填表单
        this.XZQHName = this.XZQHName+"  " + data.cityName;
        window.sessionStorage.setItem('citycodeQXName1D',this.XZQHName)
        window.sessionStorage.setItem('citycodeCunD',data.cityCode)
        this.$router.push({
          path: "/superselectiveExamination",
          query: {
            data: data.cityCode,
          },
        });
      }
    },
    handleSelectL: async function () {
      let parmes = {
        cityCode: window.sessionStorage.getItem('citycodeQXD'),
        houseUse: 6,
        masterName: "",
        pageNo: 0,
        pageSize: 0,
        roleType: window.sessionStorage.getItem('citycodeRoleD'),
      };
       if (
        window.sessionStorage.getItem("citycodeRoleD") == "0" &&
        window.sessionStorage.getItem("SelectCityD") == "1"
      ) {
        parmes.roleType = 1;
      } else if (
        window.sessionStorage.getItem("citycodeRoleD") == "0" &&
        window.sessionStorage.getItem("SelectCity") == "2"
      ) {
        parmes.roleType = 2;
      } else if (
        window.sessionStorage.getItem("citycodeRoleD") == "1" &&
        window.sessionStorage.getItem("SelectCityD") == "2"
      ) {
        parmes.roleType = 2;
      }
       const res = await houseCheckSupervisionFwCheckList(parmes);
        this.cityName = res.data.data;
        this.XZQHName = window.sessionStorage.getItem('citycodeQXNameD');
    },
  },
  mounted() {
    this.SXQ = this.$route.query.data;
    this.handleSelectL();
    //根据路由传递的data和citycode动态切换列表数据
    dd.ready(function () {
      dd.setTitle({
        title: this.SXQ,
      })
        .then((res) => {})
        .catch((err) => {
          console.error(err);
        });
    });
  },
};
</script>

<style lang="scss" scoped>
.superinspection {
  height: 100vh;
  width: 100vw;
  font-family: "Helvetica Neue", Helvetica, STHeiTi, sans-serif;
  background-color: #eee;
  overflow-y: auto;
  .ListData {
    .ListData-ul {
      background-color: white;
      // margin: 14px 10px;
      border-radius: 10px;
      padding: 14px;
      width: 93%;
      margin: 0 auto;
      margin-top: 18px;
      box-shadow: 0 0 12px #e3e3e3;
      .ListData-name {
        color: dodgerblue;
        text-decoration: underline;
        font-size: 18px;
        font-weight: 1000;
      }
      .ListData-XZQH {
        font-size: 14px;
        color: black;
        line-height: 20px;
        span {
          color: #aaa;
        }
      }
      .ListData-FWNum {
        font-size: 14px;
        color: black;
        line-height: 20px;
        span {
          color: #aaa;
        }
      }
    }
  }
}
</style>
